home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / samba / patches / samba-1.030 / samba-1
Encoding:
Text File  |  1995-09-12  |  57.3 KB  |  2,225 lines

  1. diff -u -r --new-file last-version/docs/smb.conf.5 samba-1.9.14alpha15/docs/smb.conf.5
  2. --- last-version/docs/smb.conf.5    Tue Jul 11 16:45:14 1995
  3. +++ samba-1.9.14alpha15/docs/smb.conf.5    Tue Sep 12 22:57:45 1995
  4. @@ -1197,35 +1197,24 @@
  5.  .SS mangled map (S)
  6.  This is for those who want to directly map UNIX file names which are
  7.  not representable on DOS.  The mangling of names is not always what is
  8. -needed.  In particular you may have sources for a product which runs
  9. -on Windows and UNIX on a UNIX machine.  Those sources are under RCS
  10. -and UNIX RCS wants the control files to be in a directory called RCS
  11. -which being upper case gets mangled at the Windoze end making the
  12. -files difficult to access.  What you really need is to be able to map
  13. -the UNIX name 'RCS' to the DOS name 'rcs' and to map *,v to * and the
  14. -reverse.  The first bit is easy, the second nigh on impossible!
  15. -
  16. -So to map 'RCS' to 'rcs' you put:
  17. -
  18. -  mangled map = (RCS rcs)
  19. -
  20. -Against the file share and when you create directory from the DOS
  21. -machine called rcs you get one called RCS on the UNIX machine and the
  22. -reverse.  If there is also a file called rcs on the UNIX end then you
  23. -see two files called rcs on dos and you have a problem!
  24. -
  25. -It is also possible to put a * in the names.  E.g. (*,v *) strips the
  26. -,v off the UNIX file names, but, alas it is impossible for such a
  27. -pattern to work in reverse so it is all but useless.  A pattern like
  28. -(*,a *,b) can work.  The bit which matches the * on the input side is
  29. -copied to the output side.  If you create a file fred,b on DOS you get
  30. -fred,a on UNIX etc.
  31. +needed.  In particular you may have documents with file extensiosn
  32. +that differ between dos and unix. For example, under unix it is common
  33. +to use .html for HTML files, whereas under dos .htm is more commonly
  34. +used.
  35. +
  36. +So to map 'html' to 'htm' you put:
  37. +
  38. +  mangled map = (*.html *.htm)
  39. +
  40. +One very useful case is to remove the annoying ;1 off the ends of
  41. +filenames on some CDROMS (only visible under some unixes). To do this
  42. +use a map of (*;1 *)
  43.  
  44.  .B default:
  45.      no mangled map
  46.  
  47.  .B Example:
  48. -    mangled map = (RCS rcs)
  49. +    mangled map = (*;1 *)
  50.  
  51.  .SS mangle case (S)
  52.  
  53. @@ -2198,6 +2187,10 @@
  54.  This is a boolean that controls whether to strup trailing dots off
  55.  filenames. This helps with some CDROMs that have filenames ending in a
  56.  single dot.
  57. +
  58. +NOTE: This option is now obsolete, and may be removed in future. You
  59. +should use the "mangled map" option instead as it is much more
  60. +general. 
  61.  
  62.  .SS strict locking (S)
  63.  This is a boolean that controls the handling of file locking in the
  64. diff -u -r --new-file last-version/source/Makefile samba-1.9.14alpha15/source/Makefile
  65. --- last-version/source/Makefile    Mon Sep 11 12:10:49 1995
  66. +++ samba-1.9.14alpha15/source/Makefile    Tue Sep 12 16:19:01 1995
  67. @@ -90,6 +90,15 @@
  68.  # DES_LIB= -L$(DES_BASE) -ldes
  69.  # PASSWD_FLAGS=-DSMB_PASSWD -DSMBGETPASS -DSMB_PASSWD_FILE=\"$(BASEDIR)/private/smbpasswd\"
  70.  
  71. +######################################
  72. +# VTP-Support
  73. +#
  74. +# uncomment the following two lines to enable VTP-Support
  75. +#VTP_FLAGS = -DWITH_VTP
  76. +#VTP_OBJ = vt_mode.o
  77. +######################################
  78. +
  79. +
  80.  #####################################
  81.  # WHICH OPERATING SYSTEM?
  82.  # UNCOMMENT ONE OF THE SECTIONS BELOW
  83. @@ -306,6 +315,11 @@
  84.  # FLAGSM = -DAUX
  85.  # LIBSM =
  86.  
  87. +# This is for Altos Series 386/1000
  88. +# Contributed by cal@zls.com
  89. +# FLAGSM = -DALTOS -DHAS_RDCHK
  90. +# LIBSM = -lsocket -lxenix
  91. +
  92.  
  93.  #Note: The SCO entries require the libcrypt library. You can get it via
  94.  #anonymous ftp from ftp.sco.com:/SLS/lng225b.* or ftp.uu.net:/vendors/sco
  95. @@ -405,7 +419,7 @@
  96.  CFLAGS3 = -DLOCKDIR=\"$(LOCKDIR)\" -DSMBRUN=\"$(SMBRUN)\"
  97.  CFLAGS4 = -DWORKGROUP=\"$(WORKGROUP)\" -DGUEST_ACCOUNT=\"$(GUESTACCOUNT)\" 
  98.  CFLAGS5 = $(CFLAGS1) $(CFLAGS2) $(CFLAGS3) $(CFLAGS4) $(FLAGSM) $(AFS_FLAGS) 
  99. -CFLAGS  = $(CFLAGS5) $(DCE_FLAGS) $(DES_FLAGS) $(PASSWD_FLAGS)
  100. +CFLAGS  = $(CFLAGS5) $(DCE_FLAGS) $(DES_FLAGS) $(PASSWD_FLAGS) $(VTP_FLAGS)
  101.  LIBS = $(LIBS1) $(LIBSM) $(DCE_LIBS) $(DES_LIB)
  102.  
  103.  PROGS = smbd smbclient nmbd testparm testprns smbrun smbstatus smbpasswd
  104. @@ -422,11 +436,11 @@
  105.  INCLUDES2 = pcap.h trans2.h reply.h
  106.  INCLUDES = $(INCLUDES1) $(INCLUDES2)
  107.  
  108. -UTILOBJ = util.o charset.o kanji.o fault.o smbencrypt.o charcnv.o
  109. +UTILOBJ = util.o system.o charset.o kanji.o fault.o smbencrypt.o charcnv.o
  110.  PARAMOBJ = $(UTILOBJ) loadparm.o params.o pcap.o access.o username.o ufc.o smbpass.o
  111.  SMBDOBJ1 = $(PARAMOBJ) trans2.o message.o dir.o printing.o locking.o
  112.  SMBDOBJ2 = ipc.o reply.o mangle.o chgpasswd.o password.o
  113. -SMBDOBJ = $(SMBDOBJ1) $(SMBDOBJ2)
  114. +SMBDOBJ = $(SMBDOBJ1) $(SMBDOBJ2) $(VTP_OBJ)
  115.  
  116.  .SUFFIXES:
  117.  .SUFFIXES: .c .o .h
  118. diff -u -r --new-file last-version/source/change-log samba-1.9.14alpha15/source/change-log
  119. --- last-version/source/change-log    Tue Sep 12 02:01:31 1995
  120. +++ samba-1.9.14alpha15/source/change-log    Tue Sep 12 23:01:11 1995
  121. @@ -1542,12 +1542,20 @@
  122.      - released alpha13
  123.      - fixed max_xmit bug in client
  124.      - select fix in server (fixed critical drive errors under ISC)
  125. +    - released alpha14
  126. +    - wildcard fix from Jeremy
  127. +    - changes to make IPC code more robust
  128. +    - small select loop change to reduce cleaning of share files
  129. +    - vtp, altos and mktime patches from Christian A. Lademann
  130. +    <cal@zls.com>
  131. +    - EEXIST bugfix in server.c
  132. +    - changed mangled map to apply in all cases
  133. +    - released alpha15
  134.  
  135. +
  136.  ==========
  137.  todo:
  138.  
  139. -add "strip tail" option?? (handle ;1 names)
  140. -
  141.  implement SMBmove and SMBcopy ??
  142.  
  143.  add option to print more info about locked files (full path, share name
  144. @@ -1559,17 +1567,10 @@
  145.  
  146.  no refresh/reg of new IP? or send wack and challenge owner?
  147.  
  148. -
  149.  new nmb.conf file
  150.  
  151. -winDD - check uid matching??
  152. -
  153.  protocol drop back in client to avoid openX etc.
  154.  
  155. -print queue deletion problem with mapped usernames (greyed out)
  156. -
  157. -linux bigcrypt ?
  158. -
  159.  very slow listing CD, perhaps because of order of stat and readdir?
  160.  
  161.  handle exported fat drives to a long filename capable client
  162. @@ -1588,6 +1589,4 @@
  163.  ---
  164.  ALLOW_PASSWORD_CHANGE only compiles/works on some systems
  165.  
  166. ----
  167. -The mangled map stuff doesn't seem to work in all situations
  168.  
  169. diff -u -r --new-file last-version/source/client.c samba-1.9.14alpha15/source/client.c
  170. --- last-version/source/client.c    Mon Sep 11 12:59:31 1995
  171. +++ samba-1.9.14alpha15/source/client.c    Tue Sep 12 15:56:37 1995
  172. @@ -3404,17 +3404,13 @@
  173.  #ifndef CLIX
  174.        FD_SET(fileno(stdin),&fds);
  175.  #endif
  176. -      do 
  177. -      {
  178. +
  179. +      timeout.tv_sec = 20;
  180. +      timeout.tv_usec = 0;
  181.  #ifdef CLIX
  182. -      timeout.tv_sec = 0;
  183. -#else
  184. -        timeout.tv_sec = 20;
  185. +      timeout.tv_sec = 0;
  186.  #endif
  187. -        timeout.tv_usec = 0;
  188. -        selrtn = select(255,SELECT_CAST &fds,NULL,NULL,&timeout);
  189. -      }
  190. -      while(selrtn < 0 && errno == EINTR);
  191. +      selrtn = sys_select(&fds,&timeout);
  192.        
  193.  #ifndef CLIX
  194.        if (FD_ISSET(fileno(stdin),&fds))
  195. diff -u -r --new-file last-version/source/dir.c samba-1.9.14alpha15/source/dir.c
  196. --- last-version/source/dir.c    Wed Jul  5 01:53:17 1995
  197. +++ samba-1.9.14alpha15/source/dir.c    Tue Sep 12 21:03:39 1995
  198. @@ -404,7 +404,6 @@
  199.  BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend)
  200.  {
  201.    char *dname;
  202. -  BOOL do_mangling;
  203.    BOOL found = False;
  204.    struct stat sbuf;
  205.    pstring path;
  206. @@ -412,7 +411,6 @@
  207.    BOOL isrootdir;
  208.    pstring filename;
  209.    BOOL matched;
  210. -  BOOL has_wild = (strchr(mask,'?') || strchr(mask,'*'));
  211.  
  212.    *path = *pathreal = *filename = 0;
  213.  
  214. @@ -425,7 +423,6 @@
  215.    
  216.    while (!found)
  217.      {
  218. -      extern char magic_char;
  219.        dname = ReadDirName(Connections[cnum].dirptr);
  220.  
  221.        DEBUG(6,("readdir on dirptr 0x%x now at offset %d\n",
  222. @@ -436,13 +433,10 @@
  223.        
  224.        matched = False;
  225.  
  226. -      do_mangling = ((has_wild || strchr(mask,magic_char)) && 
  227. -             lp_manglednames(SNUM(cnum)));
  228. -
  229.        strcpy(filename,dname);      
  230.  
  231.        if ((strcmp(filename,mask) == 0) ||
  232. -      (name_convert(filename,dname,do_mangling,lp_mangled_map(SNUM(cnum))) &&
  233. +      (name_convert(filename,dname,True,SNUM(cnum)) &&
  234.         mask_match(filename,mask,False,False)))
  235.      {
  236.        if (isrootdir && (strequal(filename,"..") || strequal(filename,".")))
  237. diff -u -r --new-file last-version/source/includes.h samba-1.9.14alpha15/source/includes.h
  238. --- last-version/source/includes.h    Sat Sep  2 17:49:16 1995
  239. +++ samba-1.9.14alpha15/source/includes.h    Tue Sep 12 16:21:44 1995
  240. @@ -29,6 +29,10 @@
  241.     the main OS dependent section comes later on 
  242.  */
  243.  
  244. +#ifdef ALTOS
  245. +#define NO_UTIMEH
  246. +#endif
  247. +
  248.  #ifdef MIPS
  249.  #define POSIX_H
  250.  #define NO_UTIMEH
  251. @@ -698,6 +702,39 @@
  252.  #endif
  253.  
  254.  
  255. +#ifdef ALTOS
  256. +#include <unistd.h>
  257. +#include <string.h>
  258. +#include <dirent.h>
  259. +#include <sys/fcntl.h>
  260. +#include <sys/statfs.h>
  261. +#define        const
  262. +#define        uid_t           int
  263. +#define        gid_t           int
  264. +#define        mode_t          int
  265. +#define        ptrdiff_t       int
  266. +
  267. +#define HAVE_GETGRNAM  0
  268. +
  269. +#define NO_EID
  270. +#define NO_FSYNC
  271. +#define        NO_FTRUNCATE
  272. +#define        NO_GETRLIMIT
  273. +#define        NO_INITGROUPS
  274. +#define NO_SELECT
  275. +#define NO_SETGROUPS
  276. +#define NO_STRERROR
  277. +#define NO_STRFTIME
  278. +#define        NO_TM_NAME
  279. +#define NO_UTIMEH
  280. +#define NOSTRCASECMP
  281. +#define REPLACE_MKTIME
  282. +#define REPLACE_RENAME
  283. +#define REPLACE_STRSTR
  284. +#define STATFS4
  285. +#define        USE_GETCWD
  286. +#endif
  287. +
  288.  
  289.  /*******************************************************************
  290.  end of the platform specific sections
  291. @@ -818,6 +855,10 @@
  292.  
  293.  #ifdef REPLACE_STRSTR
  294.  #define strstr(s,p) Strstr(s,p)
  295. +#endif
  296. +
  297. +#ifdef REPLACE_MKTIME
  298. +#define mktime(t) Mktime(t)
  299.  #endif
  300.  
  301.  #ifndef NGROUPS_MAX
  302. diff -u -r --new-file last-version/source/ipc.c samba-1.9.14alpha15/source/ipc.c
  303. --- last-version/source/ipc.c    Sun Sep 10 23:09:50 1995
  304. +++ samba-1.9.14alpha15/source/ipc.c    Tue Sep 12 15:02:10 1995
  305. @@ -70,30 +70,35 @@
  306.  {
  307.    pstring buf;
  308.    int l;
  309. -  strcpy(buf,src);
  310. +
  311. +  if (!src || !dst || !n || !(*dst)) return(0);
  312. +
  313. +  StrnCpy(buf,src,sizeof(buf)/2);
  314.    string_sub(buf,"%S",lp_servicename(snum));
  315.    standard_sub(cnum,buf);
  316.    StrnCpy(*dst,buf,*n);
  317.    l = strlen(*dst) + 1;
  318. -  *dst += l;
  319. -  *n -= l;
  320. +  (*dst) += l;
  321. +  (*n) -= l;
  322.    return l;
  323.  }
  324.  
  325.  static int CopyAndAdvance(char** dst, char* src, int* n)
  326.  {
  327.    int l;
  328. +  if (!src || !dst || !n || !(*dst)) return(0);
  329.    StrnCpy(*dst,src,*n);
  330.    l = strlen(*dst) + 1;
  331. -  *dst += l;
  332. -  *n -= l;
  333. +  (*dst) += l;
  334. +  (*n) -= l;
  335.    return l;
  336.  }
  337.  
  338.  static int StrlenExpanded(int cnum, int snum, char* s)
  339.  {
  340.    pstring buf;
  341. -  strcpy(buf,s);
  342. +  if (!s) return(0);
  343. +  StrnCpy(buf,s,sizeof(buf)/2);
  344.    string_sub(buf,"%S",lp_servicename(snum));
  345.    standard_sub(cnum,buf);
  346.    return strlen(buf) + 1;
  347. @@ -102,10 +107,11 @@
  348.  static char* Expand(int cnum, int snum, char* s)
  349.  {
  350.    static pstring buf;
  351. -  strcpy(buf,s);
  352. +  if (!s) return(NULL);
  353. +  StrnCpy(buf,s,sizeof(buf)/2);
  354.    string_sub(buf,"%S",lp_servicename(snum));
  355.    standard_sub(cnum,buf);
  356. -  return buf;
  357. +  return &buf[0];
  358.  }
  359.  
  360.  /****************************************************************************
  361. @@ -184,23 +190,24 @@
  362.    ****************************************************************************/
  363.  
  364.  struct pack_desc {
  365. -  char* format;            /* formatstring for structure */
  366. -  char* subformat;        /* subformat for structure */
  367. -  char* base;            /* baseaddress of buffer */
  368. -  int buflen;            /* remaining size for fixed part; on init: length of base */
  369. -  int subcount;            /* count of substructures */
  370. -  char* structbuf;        /* pointer into buffer for remaining fixed part */
  371. -  int stringlen;        /* remaining size for variable part */        
  372. -  char* stringbuf;        /* pointer into buffer for remaining variable part */
  373. -  int neededlen;        /* total needed size */
  374. -  int usedlen;            /* total used size (usedlen <= neededlen and usedlen <= buflen) */
  375. -  char* curpos;            /* current position; pointer into format or subformat */
  376. +  char* format;        /* formatstring for structure */
  377. +  char* subformat;  /* subformat for structure */
  378. +  char* base;        /* baseaddress of buffer */
  379. +  int buflen;       /* remaining size for fixed part; on init: length of base */
  380. +  int subcount;        /* count of substructures */
  381. +  char* structbuf;  /* pointer into buffer for remaining fixed part */
  382. +  int stringlen;    /* remaining size for variable part */        
  383. +  char* stringbuf;  /* pointer into buffer for remaining variable part */
  384. +  int neededlen;    /* total needed size */
  385. +  int usedlen;        /* total used size (usedlen <= neededlen and usedlen <= buflen) */
  386. +  char* curpos;        /* current position; pointer into format or subformat */
  387.    int errcode;
  388.  };
  389.  
  390.  static int get_counter(char** p)
  391.  {
  392.    int i, n;
  393. +  if (!p || !(*p)) return(0);
  394.    if (!isdigit(**p)) return 1;
  395.    for (n = 0;;) {
  396.      i = **p;
  397. @@ -215,6 +222,7 @@
  398.  static int getlen(char* p)
  399.  {
  400.    int n = 0;
  401. +  if (!p) return(0);
  402.    while (*p) {
  403.      switch( *p++ ) {
  404.      case 'W':            /* word (2 byte) */
  405. @@ -240,10 +248,14 @@
  406.    return n;
  407.  }
  408.  
  409. -static void init_package(struct pack_desc* p, int count, int subcount)
  410. +static BOOL init_package(struct pack_desc* p, int count, int subcount)
  411.  {
  412.    int n = p->buflen;
  413. -  int i = count * getlen(p->format);
  414. +  int i;
  415. +
  416. +  if (!p->format || !p->base) return(False);
  417. +
  418. +  i = count * getlen(p->format);
  419.    if (p->subformat) i += subcount * getlen(p->subformat);
  420.    p->structbuf = p->base;
  421.    p->neededlen = 0;
  422. @@ -254,12 +266,13 @@
  423.      i = n = 0;
  424.      p->errcode = NERR_BufTooSmall;
  425.    }
  426. -  else
  427. -    p->errcode = NERR_Success;
  428. +
  429. +  p->errcode = NERR_Success;
  430.    p->buflen = i;
  431.    n -= i;
  432.    p->stringbuf = p->base + i;
  433.    p->stringlen = n;
  434. +  return(p->errcode == NERR_Success);
  435.  }
  436.  
  437.  #ifdef __STDC__
  438. @@ -289,7 +302,7 @@
  439.        p->curpos = p->format;
  440.      else {
  441.        p->curpos = p->subformat;
  442. -      p->subcount--;
  443. +      if (p->subcount) p->subcount--;
  444.      }
  445.    }
  446.  #if CHECK_TYPES
  447. @@ -305,6 +318,9 @@
  448.    }
  449.  #endif
  450.    stringneeded = -1;
  451. +
  452. +  if (!p->curpos) return(0);
  453. +
  454.    switch( *p->curpos++ ) {
  455.    case 'W':            /* word (2 byte) */
  456.      needed = 2;
  457. @@ -547,6 +563,7 @@
  458.    print_status_struct status;
  459.    
  460.    bzero(&status,sizeof(status));
  461. +  bzero(&desc,sizeof(desc));
  462.   
  463.    p = skip_string(p,1);
  464.    uLevel = SVAL(p,0);
  465. @@ -574,9 +591,11 @@
  466.    if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
  467.    desc.base = *rdata;
  468.    desc.buflen = mdrcnt;
  469. -  init_package(&desc,1,count);
  470. -  desc.subcount = count;
  471. -  fill_printq_info(cnum,snum,uLevel,&desc,count,queue,&status);
  472. +  if (init_package(&desc,1,count)) {
  473. +    desc.subcount = count;
  474. +    fill_printq_info(cnum,snum,uLevel,&desc,count,queue,&status);
  475. +  }
  476. +
  477.    *rdata_len = desc.usedlen;
  478.    
  479.    *rparam_len = 6;
  480. @@ -612,8 +631,10 @@
  481.    print_queue_struct **queue = NULL;
  482.    print_status_struct *status = NULL;
  483.    int* subcntarr = NULL;
  484. -  int queuecnt, subcnt=0, succnt;
  485. +  int queuecnt, subcnt=0, succnt=0;
  486.   
  487. +  bzero(&desc,sizeof(desc));
  488. +
  489.    DEBUG(3,("DosPrintQEnum uLevel=%d\n",uLevel));
  490.   
  491.    if (strcmp(param_format,"WrLeh") != 0) return False;
  492. @@ -641,15 +662,18 @@
  493.    if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
  494.    desc.base = *rdata;
  495.    desc.buflen = mdrcnt;
  496. -  init_package(&desc,queuecnt,subcnt);
  497. -  n = 0;
  498. -  succnt = 0;
  499. -  for (i = 0; i < services; i++)
  500. -    if (lp_print_ok(i) && lp_browseable(i)) {
  501. -      fill_printq_info(cnum,i,uLevel,&desc,subcntarr[n],queue[n],&status[n]);
  502. -      n++;
  503. -      if (desc.errcode == NERR_Success) succnt = n;
  504. -    }
  505. +
  506. +  if (init_package(&desc,queuecnt,subcnt)) {
  507. +    n = 0;
  508. +    succnt = 0;
  509. +    for (i = 0; i < services; i++)
  510. +      if (lp_print_ok(i) && lp_browseable(i)) {
  511. +    fill_printq_info(cnum,i,uLevel,&desc,subcntarr[n],queue[n],&status[n]);
  512. +    n++;
  513. +    if (desc.errcode == NERR_Success) succnt = n;
  514. +      }
  515. +  }
  516. +
  517.    if (subcntarr) free(subcntarr);
  518.   
  519.    *rdata_len = desc.usedlen;
  520. @@ -1434,6 +1458,8 @@
  521.    cbBuf = SVAL(p,2);
  522.    name = p + 4;
  523.  
  524. +  bzero(&desc,sizeof(desc));
  525. +
  526.    DEBUG(3,("WWkstaUserLogon uLevel=%d name=%s\n",uLevel,name));
  527.  
  528.    /* check it's a supported varient */
  529. @@ -1444,27 +1470,29 @@
  530.    desc.buflen = mdrcnt;
  531.    desc.subformat = NULL;
  532.    desc.format = str2;
  533. -  init_package(&desc,1,0);
  534. -  PACK(&desc,"W",0);        /* code */
  535. -  PACK(&desc,"B21",name);    /* eff. name */
  536. -  PACK(&desc,"B","");        /* pad */
  537. -  PACK(&desc,"W",2);        /* priv */
  538. -  PACK(&desc,"D",0);        /* auth flags */
  539. -  PACK(&desc,"W",0);        /* num logons */
  540. -  PACK(&desc,"W",0);        /* bad pw count */
  541. -  PACK(&desc,"D",0);        /* last logon */
  542. -  PACK(&desc,"D",0);        /* last logoff */
  543. -  PACK(&desc,"D",-1);        /* logoff time */
  544. -  PACK(&desc,"D",-1);        /* kickoff time */
  545. -  PACK(&desc,"D",0);        /* password age */
  546. -  PACK(&desc,"D",0);        /* password can change */
  547. -  PACK(&desc,"D",-1);        /* password must change */
  548. -  PACK(&desc,"z",local_machine);/* computer */
  549. -  PACK(&desc,"z",lp_workgroup());/* domain */
  550. -  PACK(&desc,"z",0);        /* script path */
  551. -  PACK(&desc,"D",0);        /* reserved */
  552. -  *rdata_len = desc.usedlen;
  553. +
  554. +  if (init_package(&desc,1,0)) {
  555. +    PACK(&desc,"W",0);        /* code */
  556. +    PACK(&desc,"B21",name);    /* eff. name */
  557. +    PACK(&desc,"B","");        /* pad */
  558. +    PACK(&desc,"W",2);        /* priv */
  559. +    PACK(&desc,"D",0);        /* auth flags */
  560. +    PACK(&desc,"W",0);        /* num logons */
  561. +    PACK(&desc,"W",0);        /* bad pw count */
  562. +    PACK(&desc,"D",0);        /* last logon */
  563. +    PACK(&desc,"D",0);        /* last logoff */
  564. +    PACK(&desc,"D",-1);        /* logoff time */
  565. +    PACK(&desc,"D",-1);        /* kickoff time */
  566. +    PACK(&desc,"D",0);        /* password age */
  567. +    PACK(&desc,"D",0);        /* password can change */
  568. +    PACK(&desc,"D",-1);        /* password must change */
  569. +    PACK(&desc,"z",local_machine);/* computer */
  570. +    PACK(&desc,"z",lp_workgroup());/* domain */
  571. +    PACK(&desc,"z",0);        /* script path */
  572. +    PACK(&desc,"D",0);        /* reserved */
  573. +  }
  574.  
  575. +  *rdata_len = desc.usedlen;
  576.    *rparam_len = 6;
  577.    *rparam = REALLOC(*rparam,*rparam_len);
  578.    SSVALS(*rparam,0,desc.errcode);
  579. @@ -1544,6 +1572,9 @@
  580.    uLevel = SVAL(p,2);
  581.    cbBuf = SVAL(p,4);
  582.  
  583. +  bzero(&desc,sizeof(desc));
  584. +  bzero(&status,sizeof(status));
  585. +
  586.    DEBUG(3,("WPrintJobGetInfo uLevel=%d uJobId=0x%X\n",uLevel,uJobId));
  587.  
  588.    /* check it's a supported varient */
  589. @@ -1560,14 +1591,16 @@
  590.    if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
  591.    desc.base = *rdata;
  592.    desc.buflen = mdrcnt;
  593. -  init_package(&desc,1,0);
  594. -  if (i < count) {
  595. -    fill_printjob_info(cnum,snum,uLevel,&desc,&queue[i],i);
  596. -    *rdata_len = desc.usedlen;
  597. -  }
  598. -  else {
  599. -    desc.errcode = NERR_JobNotFound;
  600. -    *rdata_len = 0;
  601. +
  602. +  if (init_package(&desc,1,0)) {
  603. +    if (i < count) {
  604. +      fill_printjob_info(cnum,snum,uLevel,&desc,&queue[i],i);
  605. +      *rdata_len = desc.usedlen;
  606. +    }
  607. +    else {
  608. +      desc.errcode = NERR_JobNotFound;
  609. +      *rdata_len = 0;
  610. +    }
  611.    }
  612.  
  613.    *rparam_len = 6;
  614. @@ -1593,12 +1626,15 @@
  615.    char* name = p;
  616.    int uLevel,cbBuf;
  617.    int count;
  618. -  int i, succnt;
  619. +  int i, succnt=0;
  620.    int snum;
  621.    struct pack_desc desc;
  622.    print_queue_struct *queue=NULL;
  623.    print_status_struct status;
  624.  
  625. +  bzero(&desc,sizeof(desc));
  626. +  bzero(&status,sizeof(status));
  627. +
  628.    p = skip_string(p,1);
  629.    uLevel = SVAL(p,0);
  630.    cbBuf = SVAL(p,2);
  631. @@ -1623,13 +1659,15 @@
  632.    if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
  633.    desc.base = *rdata;
  634.    desc.buflen = mdrcnt;
  635. -  init_package(&desc,count,0);
  636.  
  637. -  succnt = 0;
  638. -  for (i = 0; i < count; i++) {
  639. -    fill_printjob_info(cnum,snum,uLevel,&desc,&queue[i],i);
  640. -    if (desc.errcode == NERR_Success) succnt = i+1;
  641. +  if (init_package(&desc,count,0)) {
  642. +    succnt = 0;
  643. +    for (i = 0; i < count; i++) {
  644. +      fill_printjob_info(cnum,snum,uLevel,&desc,&queue[i],i);
  645. +      if (desc.errcode == NERR_Success) succnt = i+1;
  646. +    }
  647.    }
  648. +
  649.    *rdata_len = desc.usedlen;
  650.  
  651.    *rparam_len = 8;
  652. @@ -1705,6 +1743,8 @@
  653.    struct pack_desc desc;
  654.    int snum;
  655.  
  656. +  bzero(&desc,sizeof(desc));
  657. +
  658.    p = skip_string(p,1);
  659.    uLevel = SVAL(p,0);
  660.    cbBuf = SVAL(p,2);
  661. @@ -1733,8 +1773,9 @@
  662.      if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
  663.      desc.base = *rdata;
  664.      desc.buflen = mdrcnt;
  665. -    init_package(&desc,1,0);
  666. -    fill_printdest_info(cnum,snum,uLevel,&desc);
  667. +    if (init_package(&desc,1,0)) {
  668. +      fill_printdest_info(cnum,snum,uLevel,&desc);
  669. +    }
  670.      *rdata_len = desc.usedlen;
  671.    }
  672.  
  673. @@ -1758,10 +1799,12 @@
  674.    char *p = skip_string(str2,1);
  675.    int uLevel,cbBuf;
  676.    int queuecnt;
  677. -  int i, n, succnt;
  678. +  int i, n, succnt=0;
  679.    struct pack_desc desc;
  680.    int services = lp_numservices();
  681.  
  682. +  bzero(&desc,sizeof(desc));
  683. +
  684.    uLevel = SVAL(p,0);
  685.    cbBuf = SVAL(p,2);
  686.  
  687. @@ -1779,17 +1822,18 @@
  688.    if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
  689.    desc.base = *rdata;
  690.    desc.buflen = mdrcnt;
  691. -  init_package(&desc,queuecnt,0);
  692. -
  693. -  succnt = 0;
  694. -  n = 0;
  695. -  for (i = 0; i < services; i++) {
  696. -    if (lp_print_ok(i) && lp_browseable(i)) {
  697. -      fill_printdest_info(cnum,i,uLevel,&desc);
  698. -      n++;
  699. -      if (desc.errcode == NERR_Success) succnt = n;
  700. +  if (init_package(&desc,queuecnt,0)) {    
  701. +    succnt = 0;
  702. +    n = 0;
  703. +    for (i = 0; i < services; i++) {
  704. +      if (lp_print_ok(i) && lp_browseable(i)) {
  705. +    fill_printdest_info(cnum,i,uLevel,&desc);
  706. +    n++;
  707. +    if (desc.errcode == NERR_Success) succnt = n;
  708. +      }
  709.      }
  710.    }
  711. +
  712.    *rdata_len = desc.usedlen;
  713.  
  714.    *rparam_len = 8;
  715. @@ -1815,6 +1859,8 @@
  716.    int succnt;
  717.    struct pack_desc desc;
  718.  
  719. +  bzero(&desc,sizeof(desc));
  720. +
  721.    uLevel = SVAL(p,0);
  722.    cbBuf = SVAL(p,2);
  723.  
  724. @@ -1827,9 +1873,10 @@
  725.    if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
  726.    desc.base = *rdata;
  727.    desc.buflen = mdrcnt;
  728. -  init_package(&desc,1,0);
  729. +  if (init_package(&desc,1,0)) {
  730. +    PACK(&desc,"B41","NULL");
  731. +  }
  732.  
  733. -  PACK(&desc,"B41","NULL");
  734.    succnt = (desc.errcode == NERR_Success ? 1 : 0);
  735.  
  736.    *rdata_len = desc.usedlen;
  737. @@ -1857,6 +1904,8 @@
  738.    int succnt;
  739.    struct pack_desc desc;
  740.  
  741. +  bzero(&desc,sizeof(desc));
  742. +
  743.    uLevel = SVAL(p,0);
  744.    cbBuf = SVAL(p,2);
  745.  
  746. @@ -1869,9 +1918,11 @@
  747.    if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
  748.    desc.base = *rdata;
  749.    desc.buflen = mdrcnt;
  750. -  init_package(&desc,1,0);
  751. +  desc.format = str2;
  752. +  if (init_package(&desc,1,0)) {
  753. +    PACK(&desc,"B13","lpd");
  754. +  }
  755.  
  756. -  PACK(&desc,"B13","lpd");
  757.    succnt = (desc.errcode == NERR_Success ? 1 : 0);
  758.  
  759.    *rdata_len = desc.usedlen;
  760. @@ -1899,6 +1950,8 @@
  761.    int succnt;
  762.    struct pack_desc desc;
  763.  
  764. +  bzero(&desc,sizeof(desc));
  765. +
  766.    uLevel = SVAL(p,0);
  767.    cbBuf = SVAL(p,2);
  768.  
  769. @@ -1909,11 +1962,14 @@
  770.    if (uLevel != 0 || strcmp(str2,"B9") != 0) return False;
  771.  
  772.    if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
  773. +  bzero(&desc,sizeof(desc));
  774.    desc.base = *rdata;
  775.    desc.buflen = mdrcnt;
  776. -  init_package(&desc,1,0);
  777. +  desc.format = str2;
  778. +  if (init_package(&desc,1,0)) {
  779. +    PACK(&desc,"B13","lp0");
  780. +  }
  781.  
  782. -  PACK(&desc,"B13","lp0");
  783.    succnt = (desc.errcode == NERR_Success ? 1 : 0);
  784.  
  785.    *rdata_len = desc.usedlen;
  786. diff -u -r --new-file last-version/source/local.h samba-1.9.14alpha15/source/local.h
  787. --- last-version/source/local.h    Sun Jul  9 15:12:58 1995
  788. +++ samba-1.9.14alpha15/source/local.h    Tue Sep 12 19:50:43 1995
  789. @@ -67,9 +67,7 @@
  790.  
  791.  /* shall filenames with illegal chars in them get mangled in long
  792.     filename listings? */
  793. -#if !AJT
  794.  #define MANGLE_LONG_FILENAMES 
  795. -#endif
  796.  
  797.  /* define this if you want to stop spoofing with .. and soft links
  798.     NOTE: This also slows down the server considerably */
  799. diff -u -r --new-file last-version/source/mangle.c samba-1.9.14alpha15/source/mangle.c
  800. --- last-version/source/mangle.c    Sat Sep  2 15:33:01 1995
  801. +++ samba-1.9.14alpha15/source/mangle.c    Tue Sep 12 22:04:26 1995
  802. @@ -234,7 +234,7 @@
  803.  /****************************************************************************
  804.  check for a name on the mangled name stack
  805.  ****************************************************************************/
  806. -BOOL check_mangled_stack(char *s, char *MangledMap)
  807. +BOOL check_mangled_stack(char *s)
  808.  {
  809.    int i;
  810.    pstring tmpname;
  811. @@ -254,7 +254,7 @@
  812.    for (i=0;i<mangled_stack_len;i++)
  813.      {
  814.        strcpy(tmpname,mangled_stack[i]);
  815. -      mangle_name_83(tmpname, MangledMap);
  816. +      mangle_name_83(tmpname);
  817.        if (strequal(tmpname,s))
  818.      {
  819.        strcpy(s,mangled_stack[i]);
  820. @@ -264,7 +264,7 @@
  821.      {
  822.        strcpy(tmpname,mangled_stack[i]);
  823.        strcat(tmpname,extension);
  824. -      mangle_name_83(tmpname, MangledMap);
  825. +      mangle_name_83(tmpname);
  826.        if (strequal(tmpname,s))
  827.          {
  828.            strcpy(s,mangled_stack[i]);
  829. @@ -284,9 +284,9 @@
  830.    return(False);
  831.  }    
  832.  
  833. -static char *mangled_match(char *s, /* This is null terminated */
  834. -                           char *pattern, /* This isn't. */
  835. -                           int len) /* This is the length of pattern. */
  836. +static char *map_filename(char *s, /* This is null terminated */
  837. +              char *pattern, /* This isn't. */
  838. +              int len) /* This is the length of pattern. */
  839.  {
  840.    static pstring matching_bit;  /* The bit of the string which matches */
  841.                                  /* a * in pattern if indeed there is a * */
  842. @@ -348,83 +348,6 @@
  843.    return NULL;                  /* No match. */
  844.  }
  845.  
  846. -BOOL do_rev_mangled_map(char *s, char *MangledMap)
  847. -{
  848. -  /* Does the reverse of do_fwd_mangled_map().  Look in there for
  849. -   * details.
  850. -   */
  851. -  /* Look for the start and end of each of the mapping strings using
  852. -   * these...
  853. -   */
  854. -  char *start_first=MangledMap;
  855. -  char *end_first;
  856. -  char *start_second=MangledMap;
  857. -  char *end_second;
  858. -  char *match_string;
  859. -  char *ss;                     /* Pointer into s. */
  860. -  char *pp;                     /* Pointer into pattern. */
  861. -  pstring pattern;
  862. -
  863. -  DEBUG(5,("Mangled Mapping '%s' map '%s'\n", s, MangledMap));
  864. -  while (*start_first) {
  865. -    while ((*start_first) && (*start_first != '('))
  866. -      start_first++;
  867. -    start_first++;              /* Skip the ( */
  868. -    if (!*start_first)
  869. -      continue;                 /* Always check for the end. */
  870. -    end_first = start_first;    /* Search for the ' ' or a ')' */
  871. -    DEBUG(5,("Start of first in pair '%s'\n", start_first));
  872. -    while ((*end_first) && !((*end_first == ' ') || (*end_first == ')')))
  873. -      end_first++;
  874. -    if (!*end_first) {
  875. -      start_first = end_first;
  876. -      continue;                 /* Always check for the end. */
  877. -    }
  878. -    DEBUG(5,("End of first in pair '%s'\n", end_first));
  879. -    /* Now look for the second pair. */
  880. -    start_second = end_first+1; /* Point to start of second string in */
  881. -                                /* pair. */
  882. -    DEBUG(5,("Start of second in pair '%s'\n", start_second));
  883. -    end_second = start_second;
  884. -    /* Find the end of the second of the pair. */
  885. -    while ((*end_second) && (*end_second != ')'))
  886. -      end_second++;
  887. -    if (!*end_second) {
  888. -      start_first = end_second;
  889. -      continue;               /* Always check for the end. */
  890. -    }
  891. -    DEBUG(5,("End of second in pair '%s'\n", end_second));
  892. -    if ((match_string=mangled_match(s, start_second, end_second-start_second)))
  893. -      {
  894. -    DEBUG(5,("Found a match\n"));
  895. -    /* Substitute with the new name. */
  896. -    ss = s;
  897. -    StrnCpy(pattern, start_first, end_first-start_first);
  898. -    pp = pattern;
  899. -    while ((*pp)              /* Not end of pattern. */
  900. -           && (*pp != '*'))   /* Not the wild bit. */
  901. -      *ss++ = *pp++;
  902. -    if (!*pp) {               /* The end of the pattern. */
  903. -      DEBUG(5,("s is now '%s'\n", s));
  904. -      return True;
  905. -    }
  906. -    /* Must have hit a star. */
  907. -    pp++;                     /* Skip the star. */
  908. -    strcat(ss, match_string); /* Bung in the matching bit. */
  909. -    ss += strlen(match_string);
  910. -    while ((*ss++ = *pp++))     /* Not end of pattern. */
  911. -      ;
  912. -    DEBUG(5,("s is now '%s'\n", s));
  913. -    return True;              /* DONE! */
  914. -    } else {
  915. -      start_first = end_second; /* Skip a bit which cannot be wanted */
  916. -      /* anymore. */
  917. -    }
  918. -    start_first++;
  919. -  }
  920. -  return False;
  921. -}
  922. -
  923.  
  924.  /* this is the magic char used for mangling */
  925.  char magic_char = '~';
  926. @@ -462,7 +385,8 @@
  927.      return('A' + (v-10));
  928.  }
  929.  
  930. -static BOOL do_fwd_mangled_map(char *s, char *MangledMap)
  931. +
  932. +static void do_fwd_mangled_map(char *s, char *MangledMap)
  933.  {
  934.    /* MangledMap is a series of name pairs in () separated by spaces.
  935.     * If s matches the first of the pair then the name given is the
  936. @@ -498,7 +422,7 @@
  937.        continue;                 /* Always check for the end. */
  938.      }
  939.      DEBUG(5,("End of first in pair '%s'\n", end));
  940. -    if ((match_string = mangled_match(s, start, end-start))) {
  941. +    if ((match_string = map_filename(s, start, end-start))) {
  942.        DEBUG(5,("Found a match\n"));
  943.        /* Found a match. */
  944.        start = end+1;            /* Point to start of what it is to become. */
  945. @@ -529,22 +453,18 @@
  946.        *np++ = '\0';             /* NULL terminate it. */
  947.        DEBUG(5,("End of second in pair '%s'\n", end));
  948.        strcpy(s, new_string);    /* Substitute with the new name. */
  949. -      strupper(s);
  950.        DEBUG(5,("s is now '%s'\n", s));
  951. -      return True;              /* DONE! */
  952. -    } else {
  953. -      start = end;              /* Skip a bit which cannot be wanted */
  954. -                                /* anymore. */
  955.      }
  956. +    start = end;              /* Skip a bit which cannot be wanted */
  957. +    /* anymore. */
  958.      start++;
  959.    }
  960. -  return False;
  961.  }
  962.  
  963.  /****************************************************************************
  964.  do the actual mangling to 8.3 format
  965.  ****************************************************************************/
  966. -void mangle_name_83(char *s, char *MangledMap)
  967. +void mangle_name_83(char *s)
  968.  {
  969.    int csum = str_checksum(s);
  970.    char *p;
  971. @@ -553,11 +473,6 @@
  972.    int baselen = 0;
  973.    int extlen = 0;
  974.  
  975. -  if (MangledMap && *MangledMap) {
  976. -    if (do_fwd_mangled_map(s, MangledMap))
  977. -      return;
  978. -  }
  979. -
  980.    p = strrchr(s,'.');  
  981.    if (p && (strlen(p+1)<4) )
  982.      {
  983. @@ -616,9 +531,9 @@
  984.  
  985.  
  986.  /****************************************************************************
  987. -convert a filename to 8.3 format. return True if successful.
  988. +convert a filename to DOS format. return True if successful.
  989.  ****************************************************************************/
  990. -BOOL name_convert(char *OutName,char *InName,BOOL mangle, char *MangledMap)
  991. +BOOL name_convert(char *OutName,char *InName,BOOL need83,int snum)
  992.  {
  993.    /* initially just copy it */
  994.  #ifdef KANJI
  995. @@ -627,27 +542,22 @@
  996.    strcpy(OutName,unix2dos_format(InName,False));
  997.  #endif
  998.  
  999. -  /* check if it's already in 8.3 format */
  1000. -  if (is_8_3(OutName))
  1001. -    return(True);
  1002. -
  1003. -  if (!mangle)
  1004. -    return(False);
  1005. -
  1006. -  DEBUG(5,("Converted name %s ",OutName));
  1007. -
  1008. -  /* mangle it into 8.3 */
  1009. -  push_mangled_name(OutName);  
  1010. -  mangle_name_83(OutName, MangledMap);
  1011. +  /* apply any name mappings */
  1012. +  {
  1013. +    char *map = lp_mangled_map(snum);
  1014. +    if (map && *map)
  1015. +      do_fwd_mangled_map(OutName,map);
  1016. +  }
  1017.  
  1018. -  DEBUG(5,("to %s\n",OutName));
  1019. +  /* check if it's already in 8.3 format */
  1020. +  if (need83 && !is_8_3(OutName)) {
  1021. +    if (!lp_manglednames(snum)) return(False);
  1022.  
  1023. +    /* mangle it into 8.3 */
  1024. +    push_mangled_name(OutName);  
  1025. +    mangle_name_83(OutName);
  1026. +  }
  1027.    
  1028.    return(True);
  1029.  }
  1030. -
  1031. -
  1032. -
  1033. -
  1034. -
  1035.  
  1036. diff -u -r --new-file last-version/source/nameserv.c samba-1.9.14alpha15/source/nameserv.c
  1037. --- last-version/source/nameserv.c    Sun Jul  9 16:24:33 1995
  1038. +++ samba-1.9.14alpha15/source/nameserv.c    Tue Sep 12 15:57:11 1995
  1039. @@ -1646,11 +1646,7 @@
  1040.        timeout.tv_sec = NMBD_SELECT_LOOP;
  1041.        timeout.tv_usec = 0;
  1042.  
  1043. -      while (1)
  1044. -        {
  1045. -          selrtn = select(255,SELECT_CAST &fds,NULL,NULL,&timeout);
  1046. -          if (!(selrtn < 0 && errno == EINTR)) break;
  1047. -        }
  1048. +      selrtn = sys_select(&fds,&timeout);
  1049.  
  1050.        if (!FD_ISSET(Client,&fds))
  1051.          continue;
  1052. diff -u -r --new-file last-version/source/reply.c samba-1.9.14alpha15/source/reply.c
  1053. --- last-version/source/reply.c    Sun Sep 10 23:10:16 1995
  1054. +++ samba-1.9.14alpha15/source/reply.c    Tue Sep 12 20:00:26 1995
  1055. @@ -1194,7 +1194,7 @@
  1056.    }
  1057.  
  1058.    if (is_mangled(mask))
  1059. -    check_mangled_stack(mask,NULL);
  1060. +    check_mangled_stack(mask);
  1061.  
  1062.    has_wild = strchr(mask,'*') || strchr(mask,'?');
  1063.  
  1064. @@ -2474,7 +2474,7 @@
  1065.    }
  1066.  
  1067.    if (is_mangled(mask))
  1068. -    check_mangled_stack(mask,NULL);
  1069. +    check_mangled_stack(mask);
  1070.  
  1071.    has_wild = strchr(mask,'*') || strchr(mask,'?');
  1072.  
  1073. diff -u -r --new-file last-version/source/server.c samba-1.9.14alpha15/source/server.c
  1074. --- last-version/source/server.c    Sun Sep 10 23:17:14 1995
  1075. +++ samba-1.9.14alpha15/source/server.c    Tue Sep 12 21:14:37 1995
  1076. @@ -58,6 +58,7 @@
  1077.  extern int case_default;
  1078.  extern BOOL case_sensitive;
  1079.  extern BOOL case_preserve;
  1080. +extern BOOL use_mangled_map;
  1081.  extern BOOL short_case_preserve;
  1082.  extern BOOL case_mangle;
  1083.  extern time_t smb_last_time;
  1084. @@ -292,7 +293,7 @@
  1085.      return(False);
  1086.  
  1087.    strcpy(tmpname,name2);
  1088. -  mangle_name_83(tmpname,lp_mangled_map(SNUM(current_cnum)));
  1089. +  mangle_name_83(tmpname);
  1090.  
  1091.    return(strequal(name1,tmpname));
  1092.  }
  1093. @@ -303,18 +304,18 @@
  1094.  
  1095.  If the name looks like a mangled name then try via the mangling functions
  1096.  ****************************************************************************/
  1097. -static BOOL scan_directory(char *path, char *name, char *mangled_map)
  1098. +static BOOL scan_directory(char *path, char *name,int snum)
  1099.  {
  1100.    void *cur_dir;
  1101.    char *dname;
  1102. -  BOOL mangled = is_mangled(name) || (*mangled_map);
  1103. +  BOOL mangled = is_mangled(name);
  1104.  
  1105.    /* handle null paths */
  1106.    if (*path == 0)
  1107.      path = ".";
  1108.  
  1109.    if (mangled)
  1110. -    check_mangled_stack(name,mangled_map);
  1111. +    check_mangled_stack(name);
  1112.  
  1113.    /* open the directory */
  1114.    if (!(cur_dir = OpenDir(path))) 
  1115. @@ -326,11 +327,16 @@
  1116.    /* now scan for matching names */
  1117.    while ((dname = ReadDirName(cur_dir))) 
  1118.      {
  1119. +      fstring name2;
  1120. +
  1121.        if (*dname == '.' &&
  1122.        (strequal(dname,".") || strequal(dname,"..")))
  1123.      continue;
  1124. -      if ((mangled && mangled_equal(name,dname))
  1125. -      || fname_equal(name, dname))
  1126. +
  1127. +      if (!name_convert(name2,dname,False,snum)) continue;
  1128. +
  1129. +      if ((mangled && mangled_equal(name,name2))
  1130. +      || fname_equal(name, name2))
  1131.      {
  1132.        /* we've found the file, change it's name and return */
  1133.        strcpy(name, dname);
  1134. @@ -359,7 +365,6 @@
  1135.    struct stat st;
  1136.    char *start, *end;
  1137.    pstring dirpath;
  1138. -  char *mangled_map = lp_mangled_map(SNUM(cnum));
  1139.  
  1140.    *dirpath = 0;
  1141.  
  1142. @@ -396,7 +401,7 @@
  1143.    /* a special case - if we don't have any mangling chars and are case
  1144.       sensitive then searching won't help */
  1145.    if (case_sensitive && !is_mangled(name) && 
  1146. -      !lp_strip_dot() && !(*mangled_map))
  1147. +      !lp_strip_dot() && !use_mangled_map)
  1148.      return(False);
  1149.  
  1150.    /* now we need to recursively match the name against the real 
  1151. @@ -442,7 +447,7 @@
  1152.  
  1153.        /* try to find this part of the path in the directory */
  1154.        if (strchr(start,'?') || strchr(start,'*') ||
  1155. -          !scan_directory(dirpath, start, mangled_map)) 
  1156. +          !scan_directory(dirpath, start, SNUM(cnum)))
  1157.          {
  1158.            if (end) 
  1159.          {
  1160. @@ -464,7 +469,7 @@
  1161.            /* check on the mangled stack to see if we can recover the 
  1162.           base of the filename */
  1163.            if (is_mangled(start))
  1164. -        check_mangled_stack(start,mangled_map);
  1165. +        check_mangled_stack(start);
  1166.  
  1167.            DEBUG(5,("New file %s\n",start));
  1168.            return(True); 
  1169. @@ -580,6 +585,7 @@
  1170.      if (p) *p = 0;
  1171.      if (disk_free(dname,&dum1,&dum2,&dum3) < lp_minprintspace(SNUM(cnum))) {
  1172.        close(Files[fnum].fd);
  1173. +      Files[fnum].fd = -1;
  1174.        unlink(fname);
  1175.        errno = ENOSPC;
  1176.        return;
  1177. @@ -837,7 +843,7 @@
  1178.    int share_pid=0;
  1179.  
  1180.    if ((ofun & 0x3) == 0 && file_existed) {
  1181. -    errno = ENOENT;
  1182. +    errno = EEXIST;
  1183.      return;
  1184.    }
  1185.        
  1186. @@ -845,6 +851,7 @@
  1187.      flags2 |= O_CREAT;
  1188.    if ((ofun & 0x3) == 2)
  1189.      flags2 |= O_TRUNC;
  1190. +
  1191.  #if 0
  1192.    /* append does not mean the same thing under dos and unix */
  1193.    if ((ofun & 0x3) == 1)
  1194. @@ -895,7 +902,7 @@
  1195.    DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X\n",flags,flags2));
  1196.  
  1197.    open_file(fnum,cnum,fname,flags|flags2,mode);  
  1198. -  if (!Files[fnum].open && flags==O_RDWR) {
  1199. +  if (!Files[fnum].open && flags==O_RDWR && errno!=ENOENT) {
  1200.      flags = O_RDONLY;
  1201.      *Access = 0;
  1202.      open_mode = 0;
  1203. @@ -1128,6 +1135,7 @@
  1204.    case_mangle = lp_casemangle(snum);
  1205.    case_sensitive = lp_casesensitive(snum);
  1206.    magic_char = lp_magicchar(snum);
  1207. +  use_mangled_map = (*lp_mangled_map(snum) ? True:False);
  1208.    return(True);
  1209.  }
  1210.  
  1211. @@ -3647,7 +3655,7 @@
  1212.  
  1213.        errno = 0;      
  1214.  
  1215. -      for (counter=0; 
  1216. +      for (counter=SMBD_SELECT_LOOP; 
  1217.         !receive_smb(InBuffer,SMBD_SELECT_LOOP*1000); 
  1218.         counter += SMBD_SELECT_LOOP)
  1219.      {
  1220. @@ -3724,6 +3732,14 @@
  1221.        nread = len + 4;
  1222.        
  1223.        DEBUG(3,("%s Transaction %d of length %d\n",timestring(),trans_num,nread));
  1224. +
  1225. +#ifdef WITH_VTP
  1226. +      if(trans_num == 1 && VT_Check(InBuffer)) {
  1227. +        VT_Process();
  1228. +        return;
  1229. +      }
  1230. +#endif
  1231. +
  1232.  
  1233.        if (msg_type == 0)
  1234.      show_msg(InBuffer);
  1235. diff -u -r --new-file last-version/source/smb.h samba-1.9.14alpha15/source/smb.h
  1236. --- last-version/source/smb.h    Sun Sep 10 23:10:31 1995
  1237. +++ samba-1.9.14alpha15/source/smb.h    Tue Sep 12 20:02:54 1995
  1238. @@ -560,6 +560,7 @@
  1239.  };
  1240.  
  1241.  /* and a few prototypes */
  1242. +int sys_select(fd_set *fds,struct timeval *tval);
  1243.  int interpret_character_set(char *str, int def);
  1244.  char *dos2unix_format(char *, BOOL);
  1245.  char *unix2dos_format(char *, BOOL);
  1246. @@ -618,7 +619,7 @@
  1247.  void standard_sub(int cnum,char *s);
  1248.  void del_printqueue(int cnum,int snum,int jobid);
  1249.  BOOL strisnormal(char *s);
  1250. -BOOL check_mangled_stack(char *s, char *MangledMap);
  1251. +BOOL check_mangled_stack(char *s);
  1252.  BOOL next_token(char **ptr,char *buff,char *sep);
  1253.  void invalidate_uid(int uid);
  1254.  char *fgets_slash(char *s,int maxlen,FILE *f);
  1255. @@ -693,7 +694,7 @@
  1256.  BOOL yield_connection(int cnum,char *name,int max_connections);
  1257.  int count_chars(char *s,char c);
  1258.  int smbrun(char *,char *);
  1259. -BOOL name_convert(char *OutName,char *InName,BOOL mangle, char *MangledNames);
  1260. +BOOL name_convert(char *OutName,char *InName,BOOL need83,int snum);
  1261.  struct hostent *Get_Hostbyname(char *name);
  1262.  struct passwd *Get_Pwnam(char *user,BOOL allow_change);
  1263.  void Abort(void);
  1264. @@ -714,7 +715,6 @@
  1265.  BOOL file_exist(char *fname,struct stat *sbuf);
  1266.  int read_with_timeout(int fd,char *buf,int mincnt,int maxcnt, long time_out, BOOL exact);
  1267.  void close_sockets(void );
  1268. -int write_with_timeout(int fd, char *buf, int length, long time_out);
  1269.  BOOL send_smb(char *buffer);
  1270.  BOOL send_keepalive(int client);
  1271.  int read_data(int fd,char *buffer,int N);
  1272. @@ -793,7 +793,7 @@
  1273.  int interpret_short_filename(char *p,file_info *finfo);
  1274.  int interpret_long_filename(int level,char *p,file_info *finfo);
  1275.  unsigned long interpret_addr(char *str);
  1276. -void mangle_name_83(char *s, char *MangledMap);
  1277. +void mangle_name_83(char *s);
  1278.  BOOL lp_casesignames(void);
  1279.  #if AJT
  1280.  void ajt_panic(void);
  1281. diff -u -r --new-file last-version/source/sockspy.c samba-1.9.14alpha15/source/sockspy.c
  1282. --- last-version/source/sockspy.c    Sat Apr 15 20:30:24 1995
  1283. +++ samba-1.9.14alpha15/source/sockspy.c    Tue Sep 12 15:30:53 1995
  1284. @@ -148,6 +148,7 @@
  1285.        SelectReadMask = ReadMask;
  1286.        
  1287.        /* Wait for data to be present to be moved */
  1288. +      errno = 0;
  1289.        nready = select(32,&SelectReadMask,(int *)0,(int *)0,NIL);
  1290.      } while( nready < 0  &&  errno == EINTR );
  1291.  
  1292. diff -u -r --new-file last-version/source/system.c samba-1.9.14alpha15/source/system.c
  1293. --- last-version/source/system.c    Thu Jan  1 10:00:00 1970
  1294. +++ samba-1.9.14alpha15/source/system.c    Tue Sep 12 16:14:57 1995
  1295. @@ -0,0 +1,102 @@
  1296. +/* 
  1297. +   Unix SMB/Netbios implementation.
  1298. +   Version 1.9.
  1299. +   Samba system utilities
  1300. +   Copyright (C) Andrew Tridgell 1992-1995
  1301. +   
  1302. +   This program is free software; you can redistribute it and/or modify
  1303. +   it under the terms of the GNU General Public License as published by
  1304. +   the Free Software Foundation; either version 2 of the License, or
  1305. +   (at your option) any later version.
  1306. +   
  1307. +   This program is distributed in the hope that it will be useful,
  1308. +   but WITHOUT ANY WARRANTY; without even the implied warranty of
  1309. +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1310. +   GNU General Public License for more details.
  1311. +   
  1312. +   You should have received a copy of the GNU General Public License
  1313. +   along with this program; if not, write to the Free Software
  1314. +   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1315. +*/
  1316. +
  1317. +#include "includes.h"
  1318. +
  1319. +/*
  1320. +   The idea is that this file will eventually have wrappers around all
  1321. +   important system calls in samba. The aim is twofold:
  1322. +
  1323. +   - to enable easier porting by putting OS dependent stuff in here
  1324. +
  1325. +   - to allow for hooks into other "pseudo-filesystems"
  1326. +*/
  1327. +
  1328. +
  1329. +/*******************************************************************
  1330. +this replaces the normal select() system call
  1331. +return if some data has arrived on one of the file descriptors
  1332. +return -1 means error
  1333. +********************************************************************/
  1334. +#ifdef NO_SELECT
  1335. +static int pollfd(int fd)
  1336. +{
  1337. +  int     r=0;
  1338. +
  1339. +#ifdef HAS_RDCHK
  1340. +  r = rdchk(fd);
  1341. +#endif
  1342. +
  1343. +#ifdef HAS_TCRDCHK
  1344. +  (void)ioctl(fd, TCRDCHK, &r);
  1345. +#endif
  1346. +
  1347. +#ifdef HAS_FIONREAD
  1348. +  (void)ioctl(fd, FIONREAD, &r);
  1349. +#endif
  1350. +
  1351. +  return(r);
  1352. +}
  1353. +
  1354. +int sys_select(fd_set *fds,struct timeval *tval)
  1355. +{
  1356. +  fd_set fds2;
  1357. +  int counter=0;
  1358. +  int found=0;
  1359. +
  1360. +  FD_ZERO(&fds2);
  1361. +
  1362. +  while (1) 
  1363. +    {
  1364. +      int i;
  1365. +      for (i=0;i<255;i++) {
  1366. +    if (FD_ISSET(i,fds) && pollfd(i)>0) {
  1367. +      found++;
  1368. +      FD_SET(i,&fds2);
  1369. +    }
  1370. +      }
  1371. +
  1372. +      if (found) {
  1373. +    memcpy((void *)fds,(void *)&fds2,sizeof(fds2));
  1374. +    return(found);
  1375. +      }
  1376. +      
  1377. +      if (tval && tval.tv_sec < counter) return(0);
  1378. +      sleep(1);
  1379. +      counter++;
  1380. +    }
  1381. +}
  1382. +
  1383. +#else
  1384. +int sys_select(fd_set *fds,struct timeval *tval)
  1385. +{
  1386. +  struct timeval t2;
  1387. +  int selrtn;
  1388. +
  1389. +  do {
  1390. +    if (tval) memcpy((void *)&t2,(void *)tval,sizeof(t2));
  1391. +    errno = 0;
  1392. +    selrtn = select(255,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL);
  1393. +  } while (selrtn<0 && errno == EINTR);
  1394. +
  1395. +  return(selrtn);
  1396. +}
  1397. +#endif
  1398. diff -u -r --new-file last-version/source/trans2.c samba-1.9.14alpha15/source/trans2.c
  1399. --- last-version/source/trans2.c    Sat Sep  2 17:31:55 1995
  1400. +++ samba-1.9.14alpha15/source/trans2.c    Tue Sep 12 21:27:13 1995
  1401. @@ -350,6 +350,7 @@
  1402.  
  1403.  #ifdef MANGLE_LONG_FILENAMES
  1404.    {
  1405. +    fstring fname2;
  1406.      BOOL illegal = False;
  1407.      int i;
  1408.      int l = strlen(fname);
  1409. @@ -358,11 +359,8 @@
  1410.      illegal = True;
  1411.      break;
  1412.        }
  1413. -    if (illegal) {
  1414. -      fstring fname2;
  1415. -      name_convert(fname2,fname,True,NULL);
  1416. -      strcpy(fname,fname2);
  1417. -    }    
  1418. +    name_convert(fname2,fname,illegal,SNUM(cnum));
  1419. +    strcpy(fname,fname2);
  1420.    }
  1421.  #endif
  1422.  
  1423. @@ -449,7 +447,7 @@
  1424.        SIVAL(p,0,mode); p += 4;
  1425.        SIVAL(p,0,strlen(fname)); p += 4;
  1426.        SIVAL(p,0,0); p += 4;
  1427. -      name_convert(p+2,fname,True,NULL); 
  1428. +      name_convert(p+2,fname,True,SNUM(cnum));
  1429.        strupper(p+2);
  1430.        SSVAL(p,0,strlen(p+2));
  1431.        p += 2 + 24;
  1432. diff -u -r --new-file last-version/source/util.c samba-1.9.14alpha15/source/util.c
  1433. --- last-version/source/util.c    Tue Sep 12 01:59:23 1995
  1434. +++ samba-1.9.14alpha15/source/util.c    Tue Sep 12 21:02:39 1995
  1435. @@ -74,6 +74,7 @@
  1436.     client can link easily */
  1437.  BOOL case_sensitive;
  1438.  BOOL case_preserve;
  1439. +BOOL use_mangled_map = False;
  1440.  BOOL short_case_preserve;
  1441.  BOOL case_mangle;
  1442.  
  1443. @@ -1968,13 +1969,7 @@
  1444.        FD_ZERO(&fds);
  1445.        FD_SET(fd,&fds);
  1446.        
  1447. -      do {    
  1448. -    struct timeval t2;
  1449. -    memcpy((void *)&t2,(void *)&timeout,sizeof(t2));
  1450. -    errno = 0;
  1451. -    selrtn = select(255,SELECT_CAST &fds,NULL,NULL,&t2);
  1452. -      } 
  1453. -      while( selrtn < 0  &&  errno == EINTR );
  1454. +      selrtn = sys_select(&fds,&timeout);
  1455.        
  1456.        /* Check if error */
  1457.        if(selrtn == -1)
  1458. @@ -2047,15 +2042,7 @@
  1459.    timeout.tv_sec = maxtime / 1000;
  1460.    timeout.tv_usec = (maxtime % 1000) * 1000;
  1461.  
  1462. -  do {    
  1463. -    errno = 0;
  1464. -    if (maxtime > 0)
  1465. -      selrtn = select(255,SELECT_CAST &fds,NULL,NULL,&timeout);
  1466. -    else
  1467. -      selrtn = select(255,SELECT_CAST &fds,NULL,NULL,NULL);
  1468. -  } 
  1469. -  while( selrtn < 0  &&  errno == EINTR );
  1470. -
  1471. +  selrtn = sys_select(&fds,maxtime>0?&timeout:NULL);
  1472.  
  1473.    if (!FD_ISSET(fd,&fds))
  1474.      return 0;
  1475. @@ -2077,103 +2064,6 @@
  1476.  }
  1477.  
  1478.  /****************************************************************************
  1479. -write data to a device with a timout in msec.
  1480. -****************************************************************************/
  1481. -int write_with_timeout(int fd, char *buf, int length, long time_out)
  1482. -{
  1483. -  fd_set fds;
  1484. -  int selrtn;
  1485. -  int nwritten = 0;
  1486. -  int writeret;
  1487. -  struct timeval timeout, tval1, tval2, tvaldiff;
  1488. -  if(time_out == -2)
  1489. -    time_out = DEFAULT_PIPE_TIMEOUT;
  1490. -
  1491. -  /* Blocking write */
  1492. -  if(time_out == -1) {
  1493. -    return write_data(fd, buf, length);
  1494. -  }
  1495. -  
  1496. -  /* Non blocking write */
  1497. -  if(time_out == 0) {
  1498. -    set_blocking(fd, False);
  1499. -    nwritten = write(fd, buf, length);
  1500. -    if( nwritten == -1 && errno == EWOULDBLOCK)
  1501. -      nwritten = 0;
  1502. -    set_blocking(fd,True);
  1503. -    return nwritten;
  1504. -  }
  1505. -
  1506. -  /* Most difficult - timeout write */
  1507. -
  1508. -  /* Set initial timeout */
  1509. -  timeout.tv_sec = time_out / 1000;
  1510. -  timeout.tv_usec = 1000*(time_out % 1000);
  1511. -
  1512. -  /* As most UNIXes don't modify the value of timeout
  1513. -     when they return from select we need to get the timeofday (in usec)
  1514. -     now, and also after the select returns so we know
  1515. -     how much time has elapsed */
  1516. -
  1517. -  GetTimeOfDay( &tval1);
  1518. -  nwritten = 0; /* Number of bytes we have written */
  1519. -
  1520. -  for(;;) {
  1521. -
  1522. -    FD_ZERO(&fds);
  1523. -    FD_SET(fd,&fds);
  1524. -
  1525. -    /* Wait with timeout until we can write */
  1526. -    do {    
  1527. -      struct timeval t2;
  1528. -      memcpy((void *)&t2,(void *)&timeout,sizeof(t2));
  1529. -      errno = 0;
  1530. -      selrtn = select(255,NULL,SELECT_CAST &fds,NULL,&t2);
  1531. -    } 
  1532. -    while( selrtn < 0  &&  errno == EINTR );
  1533. -
  1534. -    /* Check if error */
  1535. -    if(selrtn == -1)
  1536. -      return -1;
  1537. -
  1538. -    /* Did we timeout ? */
  1539. -    if (selrtn == 0 )
  1540. -      break; /* Yes */
  1541. -
  1542. -    /* Set the fd nonblocking and write as much as we can */
  1543. -    set_blocking(fd, False);
  1544. -    writeret = write( fd, buf+nwritten, length-nwritten );
  1545. -    set_blocking(fd,True);
  1546. -    if(writeret == -1)
  1547. -      return -1;
  1548. -    nwritten += writeret;
  1549. -
  1550. -    /* If we have written more than length then return */
  1551. -    if( nwritten >= length )
  1552. -      break;
  1553. -
  1554. -    /* We need to do another select - but first reduce the
  1555. -     time_out by the amount of time already elapsed - if
  1556. -     this is less than zero then return */
  1557. -    GetTimeOfDay( &tval2);
  1558. -    (void)tval_sub( &tvaldiff, &tval2, &tval1);
  1559. -
  1560. -    if( tval_sub( &timeout, &timeout, &tvaldiff) <= 0) {
  1561. -      /* We timed out */
  1562. -      break;
  1563. -    }
  1564. -    
  1565. -    /* Save the time of day as we need to do the 
  1566. -       select again (saves a system call)*/
  1567. -    tval1 = tval2;
  1568. -  }
  1569. -  /* Return the number we got */
  1570. -  return(nwritten);
  1571. -}
  1572. -
  1573. -
  1574. -/****************************************************************************
  1575.  send a keepalive packet (rfc1002)
  1576.  ****************************************************************************/
  1577.  BOOL send_keepalive(int client)
  1578. @@ -2651,7 +2541,7 @@
  1579.   
  1580.      FD_ZERO(&fds);
  1581.      errno = 0;
  1582. -    select(255,NULL,SELECT_CAST &fds,NULL,&tval);
  1583. +    sys_select(&fds,&tval);
  1584.  
  1585.      GetTimeOfDay(&t2);
  1586.      tdiff = TvalDiff(&t1,&t2);
  1587. @@ -2842,11 +2732,13 @@
  1588.    StrnCpy(p1,regexp,sizeof(pstring)-1);
  1589.    StrnCpy(p2,str,sizeof(pstring)-1);
  1590.  
  1591. +#if 0
  1592.    if (strchr(p1,'.'))
  1593.      {
  1594.        string_sub(p1,"*.*","*");
  1595.        string_sub(p1,".*","*");
  1596.      }
  1597. +#endif
  1598.  
  1599.    /* Remove any *? and ** as they are meaningless */
  1600.    for(p = p1; *p; p++)
  1601. @@ -4206,6 +4098,65 @@
  1602.      return NULL;
  1603.  }
  1604.  #endif /* REPLACE_STRSTR */
  1605. +
  1606. +
  1607. +#ifdef REPLACE_MKTIME
  1608. +/*******************************************************************
  1609. +a mktime() replacement for those who don't have it - contributed by 
  1610. +C.A. Lademann <cal@zls.com>
  1611. +********************************************************************/
  1612. +#define  MINUTE  60
  1613. +#define  HOUR    60*MINUTE
  1614. +#define  DAY             24*HOUR
  1615. +#define  YEAR    365*DAY
  1616. +time_t Mktime(struct tm      *t)
  1617. +{
  1618. +  struct tm       *u;
  1619. +  time_t  epoch = 0;
  1620. +  int             mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
  1621. +  y, m, i;
  1622. +
  1623. +  if(t->tm_year < 70)
  1624. +    return((time_t)-1);
  1625. +
  1626. +  epoch = (t->tm_year - 70) * YEAR + 
  1627. +    (t->tm_year / 4 - 70 / 4 - t->tm_year / 100) * DAY;
  1628. +
  1629. +  y = t->tm_year;
  1630. +  m = 0;
  1631. +
  1632. +  for(i = 0; i < t->tm_mon; i++) {
  1633. +    epoch += mon [m] * DAY;
  1634. +    if(m == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))
  1635. +      epoch += DAY;
  1636. +    
  1637. +    if(++m > 11) {
  1638. +      m = 0;
  1639. +      y++;
  1640. +    }
  1641. +  }
  1642. +
  1643. +  epoch += (t->tm_mday - 1) * DAY;
  1644. +  epoch += t->tm_hour * HOUR + t->tm_min * MINUTE + t->tm_sec;
  1645. +  
  1646. +  if((u = localtime(&epoch)) != NULL) {
  1647. +    t->tm_sec = u->tm_sec;
  1648. +    t->tm_min = u->tm_min;
  1649. +    t->tm_hour = u->tm_hour;
  1650. +    t->tm_mday = u->tm_mday;
  1651. +    t->tm_mon = u->tm_mon;
  1652. +    t->tm_year = u->tm_year;
  1653. +    t->tm_wday = u->tm_wday;
  1654. +    t->tm_yday = u->tm_yday;
  1655. +    t->tm_isdst = u->tm_isdst;
  1656. +#ifndef NO_TM_NAME
  1657. +    memcpy(t->tm_name, u->tm_name, LTZNMAX);
  1658. +#endif
  1659. +  }
  1660. +
  1661. +  return(epoch);
  1662. +}
  1663. +#endif /* REPLACE_MKTIME */
  1664.  
  1665.  
  1666.  
  1667. diff -u -r --new-file last-version/source/version.h samba-1.9.14alpha15/source/version.h
  1668. --- last-version/source/version.h    Tue Sep 12 02:05:19 1995
  1669. +++ samba-1.9.14alpha15/source/version.h    Tue Sep 12 23:01:25 1995
  1670. @@ -1 +1 @@
  1671. -#define VERSION "1.9.14alpha14"
  1672. +#define VERSION "1.9.14alpha15"
  1673. diff -u -r --new-file last-version/source/vt_mode.c samba-1.9.14alpha15/source/vt_mode.c
  1674. --- last-version/source/vt_mode.c    Thu Jan  1 10:00:00 1970
  1675. +++ samba-1.9.14alpha15/source/vt_mode.c    Tue Sep 12 16:28:49 1995
  1676. @@ -0,0 +1,495 @@
  1677. +/* vt_mode.c */
  1678. +/*
  1679. +support vtp-sessions
  1680. +
  1681. +written by Christian A. Lademann <cal@zls.com>
  1682. +*/
  1683. +
  1684. +/*
  1685. +02.05.95:cal:ported to samba-1.9.13
  1686. +*/
  1687. +
  1688. +#define    __vt_mode_c__
  1689. +
  1690. +
  1691. +/* #include    <stdio.h> */
  1692. +/* #include    <fcntl.h> */
  1693. +/* #include    <sys/types.h> */
  1694. +/* #include    <unistd.h> */
  1695. +/* #include    <signal.h> */
  1696. +/* #include    <errno.h> */
  1697. +/* #include    <ctype.h> */
  1698. +/* #include    <utmp.h> */
  1699. +/* #include    <sys/param.h> */
  1700. +/* #include    <sys/ioctl.h> */
  1701. +/* #include    <stdlib.h> */
  1702. +/* #include    <string.h> */
  1703. +
  1704. +#include    "includes.h"
  1705. +#include    "vt_mode.h"
  1706. +#include    <utmp.h>
  1707. +
  1708. +#ifdef SCO
  1709. +    extern char    *strdup();
  1710. +#endif
  1711. +
  1712. +
  1713. +#ifdef LINUX
  1714. +#    define    HAS_VTY
  1715. +#endif
  1716. +
  1717. +#ifdef SCO
  1718. +#    define    HAS_PTY
  1719. +#    define    HAS_VTY
  1720. +
  1721. +#    include    <sys/tty.h>
  1722. +#endif
  1723. +
  1724. +extern int    DEBUGLEVEL;
  1725. +extern char    *InBuffer, *OutBuffer;
  1726. +extern int    done_become_user;
  1727. +
  1728. +char    master_name [64], slave_name [64];
  1729. +int        master, slave, i, o, e;
  1730. +
  1731. +int        ms_type = MS_NONE,
  1732. +        ms_poll = 0;
  1733. +
  1734. +
  1735. +/*
  1736. +VT_Check: test incoming packet for "vtp" or "iVT1\0"
  1737. +*/
  1738. +int    VT_Check(buffer)
  1739. +char    *buffer;
  1740. +{
  1741. +    DEBUG(3,("Checking packet: <%10s...>\n", buffer+4));
  1742. +    if((strncmp(buffer+4, "vtp", 3) == 0 && smb_len(buffer) == 3) || (strncmp(buffer+4, "iVT1\0", 5) == 0 && smb_len(buffer) == 5))
  1743. +        return(1);
  1744. +    else
  1745. +        return(0);
  1746. +}
  1747. +
  1748. +
  1749. +/*
  1750. +VT_Start_utmp: prepare /etc/utmp for /bin/login
  1751. +*/
  1752. +VT_Start_utmp()
  1753. +{
  1754. +    struct utmp    u, *v;
  1755. +    char        *tt;
  1756. +
  1757. +
  1758. +    setutent();
  1759. +
  1760. +    strcpy(u.ut_line, VT_Line);
  1761. +
  1762. +    if((v = getutline(&u)) == NULL) {
  1763. +        if(strncmp(VT_Line, "tty", 3) == 0)
  1764. +            tt = VT_Line + 3;
  1765. +        else if(strlen(VT_Line) > 4)
  1766. +            tt = VT_Line + strlen(VT_Line) - 4;
  1767. +        else
  1768. +            tt = VT_Line;
  1769. +
  1770. +        strcpy(u.ut_id, tt);
  1771. +        u.ut_time = time((time_t*)0);
  1772. +    }
  1773. +
  1774. +    strcpy(u.ut_user, "LOGIN");
  1775. +    strcpy(u.ut_line, VT_Line);
  1776. +    u.ut_pid = getpid();
  1777. +    u.ut_type = LOGIN_PROCESS;
  1778. +    pututline(&u);
  1779. +
  1780. +    endutent();
  1781. +
  1782. +    return(0);
  1783. +}
  1784. +
  1785. +
  1786. +/*
  1787. +VT_Stop_utmp: prepare /etc/utmp for other processes
  1788. +*/
  1789. +VT_Stop_utmp()
  1790. +{
  1791. +    struct utmp    u, *v;
  1792. +
  1793. +
  1794. +    if(VT_Line != NULL) {
  1795. +        setutent();
  1796. +
  1797. +        strcpy(u.ut_line, VT_Line);
  1798. +
  1799. +        if((v = getutline(&u)) != NULL) {
  1800. +            strcpy(v->ut_user, "");
  1801. +            v->ut_type = DEAD_PROCESS;
  1802. +            v->ut_time = time((time_t*)0);
  1803. +            pututline(v);
  1804. +        }
  1805. +
  1806. +        endutent();
  1807. +    }
  1808. +
  1809. +    return(0);
  1810. +}
  1811. +
  1812. +
  1813. +/*
  1814. +VT_AtExit: Things to do when the program exits
  1815. +*/
  1816. +void    VT_AtExit()
  1817. +{
  1818. +    if(VT_ChildPID > 0) {
  1819. +        kill(VT_ChildPID, SIGHUP);
  1820. +        (void)wait(NULL);
  1821. +    }
  1822. +
  1823. +    VT_Stop_utmp();
  1824. +}
  1825. +
  1826. +
  1827. +/*
  1828. +VT_SigCLD: signalhandler for SIGCLD: set flag if child-process died
  1829. +*/
  1830. +void    VT_SigCLD(sig)
  1831. +int    sig;
  1832. +{
  1833. +    if(wait(NULL) == VT_ChildPID)
  1834. +        VT_ChildDied = True;
  1835. +    else
  1836. +        signal(SIGCLD, VT_SigCLD);
  1837. +}
  1838. +
  1839. +
  1840. +/*
  1841. +VT_SigEXIT: signalhandler for signals that cause the process to exit
  1842. +*/
  1843. +void    VT_SigEXIT(sig)
  1844. +int    sig;
  1845. +{
  1846. +    VT_AtExit();
  1847. +
  1848. +    exit(1);
  1849. +}
  1850. +
  1851. +
  1852. +/*
  1853. +VT_Start: initialize vt-specific data, alloc pty, spawn shell and send ACK
  1854. +*/
  1855. +int    VT_Start()
  1856. +{
  1857. +    char    OutBuf [64], *X, *Y;
  1858. +
  1859. +
  1860. +    ms_type = MS_NONE;
  1861. +    master = slave = -1;
  1862. +
  1863. +#ifdef HAS_VTY
  1864. +#ifdef LINUX
  1865. +#    define    MASTER_TMPL    "/dev/pty  "
  1866. +#    define    SLAVE_TMPL    "/dev/tty  "
  1867. +#    define    LETTER1        "pqrs"
  1868. +#    define    POS1        8
  1869. +#    define    LETTER2        "0123456789abcdef"
  1870. +#    define    POS2        9
  1871. +#endif
  1872. +
  1873. +#ifdef SCO
  1874. +#    define    MASTER_TMPL    "/dev/ptyp_  "
  1875. +#    define    SLAVE_TMPL    "/dev/ttyp_  "
  1876. +#    define    LETTER1        "0123456"
  1877. +#    define    POS1        10
  1878. +#    define    LETTER2        "0123456789abcdef"
  1879. +#    define    POS2        11
  1880. +#endif
  1881. +
  1882. +    if(ms_poll == MS_VTY || ms_poll == 0) {
  1883. +        strcpy(master_name, MASTER_TMPL);
  1884. +        strcpy(slave_name, SLAVE_TMPL);
  1885. +
  1886. +        for(X = LETTER1; *X && master < 0; X++)
  1887. +            for(Y = LETTER2; *Y && master < 0; Y++) {
  1888. +                master_name [POS1] = *X;
  1889. +                master_name [POS2] = *Y;
  1890. +                if((master = open(master_name, O_RDWR)) >= 0) {
  1891. +                    slave_name [POS1] = *X;
  1892. +                    slave_name [POS2] = *Y;
  1893. +                    if((slave = open(slave_name, O_RDWR)) < 0)
  1894. +                        close(master);
  1895. +                }
  1896. +            }
  1897. +
  1898. +        if(master >= 0 && slave >= 0)
  1899. +            ms_type = MS_VTY;
  1900. +    }
  1901. +
  1902. +#    undef    MASTER_TMPL
  1903. +#    undef    SLAVE_TMPL
  1904. +#    undef    LETTER1
  1905. +#    undef    LETTER2
  1906. +#    undef    POS1
  1907. +#    undef    POS2
  1908. +#endif
  1909. +
  1910. +
  1911. +#ifdef HAS_PTY
  1912. +#ifdef SCO
  1913. +#    define    MASTER_TMPL    "/dev/ptyp%d"
  1914. +#    define    SLAVE_TMPL    "/dev/ttyp%d"
  1915. +#    define    MIN_I        0
  1916. +#    define    MAX_I        63
  1917. +#endif
  1918. +
  1919. +    if(ms_poll == MS_PTY || ms_poll == 0) {
  1920. +        int    i;
  1921. +
  1922. +        for(i = MIN_I; i <= MAX_I && master < 0; i++) {
  1923. +            sprintf(master_name, MASTER_TMPL, i);
  1924. +            if((master = open(master_name, O_RDWR)) >= 0) {
  1925. +                sprintf(slave_name, SLAVE_TMPL, i);
  1926. +                if((slave = open(slave_name, O_RDWR)) < 0)
  1927. +                    close(master);
  1928. +            }
  1929. +        }
  1930. +
  1931. +        if(master >= 0 && slave >= 0)
  1932. +            ms_type = MS_PTY;
  1933. +    }
  1934. +
  1935. +#    undef    MASTER_TMPL
  1936. +#    undef    SLAVE_TMPL
  1937. +#    undef    MIN_I
  1938. +#    undef    MAX_I
  1939. +#endif
  1940. +
  1941. +
  1942. +    if(! ms_type)
  1943. +        return(-1);
  1944. +
  1945. +    VT_Line = strdup(strrchr(slave_name, '/') + 1);
  1946. +
  1947. +    switch((VT_ChildPID = fork())) {
  1948. +    case -1:
  1949. +        return(-1);
  1950. +        break;
  1951. +
  1952. +    case 0:
  1953. +#ifdef SCO
  1954. +        setsid();
  1955. +#endif
  1956. +        close(0);
  1957. +        close(1);
  1958. +        close(2);
  1959. +
  1960. +        i = open(slave_name, O_RDWR);
  1961. +        o = open(slave_name, O_RDWR);
  1962. +        e = open(slave_name, O_RDWR);
  1963. +
  1964. +#ifdef LINUX
  1965. +        setsid();
  1966. +        if (ioctl(slave, TIOCSCTTY, (char *)NULL) == -1)
  1967. +            exit(1);
  1968. +#endif
  1969. +#ifdef SCO
  1970. +        tcsetpgrp(0, getpid());
  1971. +#endif
  1972. +
  1973. +        VT_Start_utmp();
  1974. +
  1975. +        system("stty sane");
  1976. +        execlp("/bin/login", "login", "-c", (char*)0);
  1977. +        exit(1);
  1978. +        break;
  1979. +
  1980. +    default:
  1981. +        VT_Mode = True;
  1982. +        VT_Status = VT_OPEN;
  1983. +        VT_ChildDied = False;
  1984. +        VT_Fd = master;
  1985. +
  1986. +        signal(SIGCLD, VT_SigCLD);
  1987. +
  1988. +        signal(SIGHUP, VT_SigEXIT);
  1989. +        signal(SIGTERM, VT_SigEXIT);
  1990. +        signal(SIGINT, VT_SigEXIT);
  1991. +        signal(SIGQUIT, VT_SigEXIT);
  1992. +
  1993. +        memset(OutBuf, 0, sizeof(OutBuf));
  1994. +        OutBuf [4] = 0x06;
  1995. +        _smb_setlen(OutBuf, 1);
  1996. +
  1997. +        send_smb(OutBuf);
  1998. +
  1999. +        return(0);
  2000. +        break;
  2001. +    }
  2002. +}
  2003. +
  2004. +
  2005. +/*
  2006. +VT_Output: transport data from socket to pty
  2007. +*/
  2008. +int    VT_Output(Buffer)
  2009. +char    *Buffer;
  2010. +{
  2011. +    int        i, len, nb;
  2012. +
  2013. +
  2014. +    if(VT_Status != VT_OPEN)
  2015. +        return(-1);
  2016. +
  2017. +    len = smb_len(Buffer);
  2018. +
  2019. +    nb = write(VT_Fd, Buffer + 4, len);
  2020. +
  2021. +    return((nb == len) ? 0 : -1);
  2022. +}
  2023. +
  2024. +
  2025. +/*
  2026. +VT_Input: transport data from pty to socket
  2027. +*/
  2028. +int    VT_Input(Buffer, Size)
  2029. +char    *Buffer;
  2030. +int        Size;
  2031. +{
  2032. +    int        len;
  2033. +
  2034. +
  2035. +    if(VT_Status != VT_OPEN)
  2036. +        return(-1);
  2037. +
  2038. +    memset(Buffer, 0, Size);
  2039. +    len = read(VT_Fd, Buffer + 4, MIN(VT_MAXREAD, Size));
  2040. +
  2041. +    _smb_setlen(Buffer, len);
  2042. +
  2043. +    return(len + 4);
  2044. +}
  2045. +
  2046. +
  2047. +/*
  2048. +VT_Process: main loop while in vt-mode
  2049. +*/
  2050. +void VT_Process()
  2051. +{
  2052. +    static int    trans_num = 0;
  2053. +    extern int    Client;
  2054. +    int            nread;
  2055. +
  2056. +
  2057. +    VT_Start();
  2058. +
  2059. +    atexit(VT_AtExit);
  2060. +
  2061. +    while (True) {
  2062. +        int32            len;      
  2063. +        int                msg_type;
  2064. +        int                msg_flags;
  2065. +        int                counter;
  2066. +        int                last_keepalive=0;
  2067. +        struct fd_set    si;
  2068. +        struct timeval    to, *top;
  2069. +        int                n, ret, t;
  2070. +
  2071. +
  2072. +        errno = 0;
  2073. +        t = SMBD_SELECT_LOOP*1000;
  2074. +
  2075. +
  2076. +        FD_ZERO(&si);
  2077. +        FD_SET(Client, &si);
  2078. +
  2079. +        FD_SET(VT_Fd, &si);
  2080. +
  2081. +        if(t >= 0) {
  2082. +            to.tv_sec = t / 1000;
  2083. +            to.tv_usec = t - (to.tv_sec * 1000);
  2084. +
  2085. +            top = &to;
  2086. +        } else
  2087. +            top = NULL;
  2088. +
  2089. +        if(VT_ChildDied)
  2090. +            goto leave_VT_Process;
  2091. +
  2092. +        n = select(MAX(VT_Fd, Client) + 1, &si, NULL, NULL, top);
  2093. +
  2094. +        if(VT_ChildDied)
  2095. +            goto leave_VT_Process;
  2096. +    
  2097. +        if(n == 0) {
  2098. +            int i;
  2099. +            time_t t;
  2100. +            BOOL allidle = True;
  2101. +            extern int keepalive;
  2102. +    
  2103. +            counter += SMBD_SELECT_LOOP;
  2104. +
  2105. +            t = time(NULL);
  2106. +    
  2107. +            if (keepalive && (counter-last_keepalive)>keepalive) {
  2108. +                if (!send_keepalive(Client))
  2109. +                    goto leave_VT_Process;
  2110. +                last_keepalive = counter;
  2111. +            }
  2112. +        } else if(n > 0) {
  2113. +            counter = 0;
  2114. +
  2115. +            if(FD_ISSET(VT_Fd, &si)) {
  2116. +                /* got input from vt */
  2117. +                nread = VT_Input(OutBuffer, MIN(BUFFER_SIZE,lp_maxxmit()));
  2118. +
  2119. +                if(nread > 0)
  2120. +                    send_smb(OutBuffer);
  2121. +            }
  2122. +
  2123. +            if(FD_ISSET(Client, &si)) {
  2124. +                /* got input from socket */
  2125. +
  2126. +                if(receive_smb(InBuffer, 0)) {
  2127. +                    msg_type = CVAL(InBuffer,0);
  2128. +                    msg_flags = CVAL(InBuffer,1);
  2129. +    
  2130. +                    len = smb_len(InBuffer);
  2131. +    
  2132. +                    DEBUG(6,("got message type 0x%x of len 0x%x\n",msg_type,len));
  2133. +    
  2134. +                    nread = len + 4;
  2135. +          
  2136. +                    DEBUG(3,("%s Transaction %d of length %d\n",timestring(),trans_num,nread));
  2137. +    
  2138. +                    if(msg_type == 0)
  2139. +                        VT_Output(InBuffer);
  2140. +                    else {
  2141. +                        nread = construct_reply(InBuffer,OutBuffer,nread,MIN(BUFFER_SIZE,lp_maxxmit()));
  2142. +         
  2143. +                        if(nread > 0) {
  2144. +                            if (nread != smb_len(OutBuffer) + 4) {
  2145. +                                DEBUG(0,("ERROR: Invalid message response size! %d %d\n",
  2146. +                                    nread,
  2147. +                                    smb_len(OutBuffer)));
  2148. +                            } else
  2149. +                                send_smb(OutBuffer);
  2150. +                        }
  2151. +                    }
  2152. +                } else
  2153. +                    if(errno == EBADF)
  2154. +                        goto leave_VT_Process;
  2155. +            }
  2156. +        }
  2157. +
  2158. +        trans_num++;
  2159. +    }
  2160. +
  2161. +    leave_VT_Process:
  2162. +/*
  2163. +        if(VT_ChildPID > 0)
  2164. +            kill(VT_ChildPID, SIGHUP);
  2165. +
  2166. +        VT_Stop_utmp(VT_Line);
  2167. +        return;
  2168. +*/
  2169. +        close_sockets();
  2170. +        exit(0);
  2171. +}
  2172. diff -u -r --new-file last-version/source/vt_mode.h samba-1.9.14alpha15/source/vt_mode.h
  2173. --- last-version/source/vt_mode.h    Thu Jan  1 10:00:00 1970
  2174. +++ samba-1.9.14alpha15/source/vt_mode.h    Tue Sep 12 16:29:04 1995
  2175. @@ -0,0 +1,48 @@
  2176. +/* vt_mode.h */
  2177. +/*
  2178. +support vtp-sessions
  2179. +
  2180. +written by Christian A. Lademann <cal@zls.com>
  2181. +*/
  2182. +
  2183. +/*
  2184. +02.05.95:cal:ported to samba-1.9.13
  2185. +*/
  2186. +
  2187. +#ifndef    __vt_mode_h__
  2188. +#    define    __vt_mode_h__
  2189. +
  2190. +#    define    VT_CLOSED    0
  2191. +#    define    VT_OPEN        1
  2192. +
  2193. +#    define    MS_NONE        0
  2194. +#    define    MS_PTY        1
  2195. +#    define    MS_STREAM    2
  2196. +#    define    MS_VTY        3
  2197. +
  2198. +#    define    VT_MAXREAD    32
  2199. +
  2200. +
  2201. +#    undef    EXTERN
  2202. +
  2203. +#    ifndef __vt_mode_c__
  2204. +#        define    EXTERN    extern
  2205. +#        define    DEFAULT(v)
  2206. +#    else
  2207. +#        define    EXTERN
  2208. +#        define    DEFAULT(v)    =(v)
  2209. +#    endif
  2210. +
  2211. +    EXTERN int    VT_Status        DEFAULT(VT_CLOSED),
  2212. +                VT_Fd            DEFAULT(-1),
  2213. +                VT_ChildPID        DEFAULT(-1);
  2214. +
  2215. +    EXTERN BOOL    VT_Mode            DEFAULT(False),
  2216. +                VT_ChildDied    DEFAULT(False);
  2217. +
  2218. +    EXTERN char    *VT_Line        DEFAULT(NULL);
  2219. +
  2220. +#    undef    EXTERN
  2221. +
  2222. +
  2223. +#endif /* __vt_mode_h__ */
  2224.